﻿using System;
using System.Collections.Generic;
using GpgApi;
using Microsoft.Office.Interop.Outlook;

namespace WgpgOutlookPlugin
{
    public static class OutlookUtils
    {
        public static List<Email> GetRecipientsFromMailItem(MailItem mailItem)
        {
            List<Email> emails = new List<Email>();

            if (mailItem == null)
                return emails;

            Recipients recipients = mailItem.Recipients;
            foreach (Recipient recipient in recipients)
            {
                String tmp = recipient.Address;
                if (Email.IsValid(tmp))
                {
                    Email tmpEmail = new Email(tmp);
                    if (!emails.Contains(tmpEmail))
                        emails.Add(new Email(tmp));
                }
            }

            return emails;
        }
    }
}
